﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>登录</title>
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <link href="~/layui/css/login.css" rel="stylesheet" />
    <link href="~/icomoon/style.css" rel="stylesheet" />
</head>
<body>
    <div class="layadmin-user-login" id="LAY-user-login" >
        <div class="layadmin-user-login-main">
            <div class="layadmin-user-login-box layadmin-user-login-header">
                <h2>管理系统</h2>
                <p>登录</p>
            </div>
            <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon icon-user" for="usercode"></label>
                    <input type="text" name="usercode" id="usercode" lay-verify="required" placeholder="用户名" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <label class="layadmin-user-login-icon layui-icon icon-lock" for="password"></label>
                    <input type="password" name="password" id="password" lay-verify="required" placeholder="密码" class="layui-input">
                </div>
                <div class="layui-form-item">
                    <button class="layui-btn layui-btn-fluid" lay-submit="" lay-filter="user-login-submit">登 入</button>
                </div>
            </div>
        </div>
    </div>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
    <script src="~/layui/layui.js"></script>
    <script>
        //JavaScript代码区域
        layui.use('form', function () {
            var form = layui.form;
            //监听提交
            form.on('submit(user-login-submit)', function (data) {
                $.post("/login", data.field, function (result) {
                    if (result.success) {
                        layer.msg(result.message, {
                            offset: '15px'
                            , icon: 1
                            , time: 1000
                        }, function () {
                            location.href = '/home/index';
                        });
                    } else {
                        layer.msg(result.message, {
                            offset: '15px'
                            , icon: 2
                        });
                    }
                });
                return false;
            });
        });
    </script>
</body>
</html>
